/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.hires.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.sql.Timestamp;
import java.io.Serializable;

/**
 * @author 毛晋辉
 * @description /
 * @date 2020-09-06
 **/
@Entity
@Data
@Table(name = "hires")
public class Hires extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "user_id")
    @ApiModelProperty(value = "发布人id")
    private String userId;


    @NotBlank(message = "请填写标题")
    @Column(name = "title")
    @ApiModelProperty(value = "标题")
    private String title;

    @NotNull(message = "请选择职位类型")
    @Column(name = "job_type")
    @ApiModelProperty(value = "职位类型")
    private Integer jobType;

    @NotBlank(message = "请填写薪资描述")
    @Column(name = "salary")
    @ApiModelProperty(value = "薪资描述")
    private String salary;

    @NotBlank(message = "请填写招聘人数")
    @Column(name = "num")
    @ApiModelProperty(value = "招聘人数")
    private String num;


    @Column(name = "address")
    @ApiModelProperty(value = "单位地址")
    private String address;

    @Column(name = "job_duty")
    @ApiModelProperty(value = "工作职责（json）")
    private String jobDuty;


    @Column(name = "status")
    @ApiModelProperty(value = "状态：0待审核；1审核通过；2审核失败")
    private Integer status;

    @Column(name = "start_time")
    @ApiModelProperty(value = "生效时间")
    private Timestamp startTime;

    @Column(name = "end_time")
    @ApiModelProperty(value = "失效时间")
    private Timestamp endTime;

    @Column(name = "job_requires")
    @ApiModelProperty(value = "任职要求（json）")
    private String jobRequires;

    @Column(name = "job_benefits")
    @ApiModelProperty(value = "福利待遇")
    private String jobBenefits;


    @Pattern(regexp = "((\\d{11})|^((\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d)|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d))$)",
            message = "请输入正确的手机号或者固定电话")
    @NotBlank(message = "请填写联系电话")
    @Column(name = "tel")
    @ApiModelProperty(value = "联系电话")
    private String tel;

    public void copy(Hires source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}